#include <string>
#include <list>
#include <iostream>
#include <algorithm>

using namespace std;


void Find_first_ofTest()
{
	list<string> lStrA, lStrB;	
	string str;

	cout << "list A: " << endl; 
	while(cin>>str && str != "q")
	{
		lStrA.push_back(str);
	}

	cout << "list B: " << endl; 
	while(cin>>str && str != "q")
	{
		lStrB.push_back(str);
	}

	list<string>::size_type count = 0;
	list<string>::iterator it = lStrA.begin();
	while((it = find_first_of(it, lStrA.end(), lStrB.begin(), lStrB.end())) != lStrA.end())
	{
		++ count;
		++ it;
	}
	cout << "Found " << count << " names on both list" << endl;
}